package cn.xutongxue.common.excption;

import cn.xutongxue.common.enums.Errors;
import lombok.Getter;

/**
 * 自定义异常类
 */
@Getter
public class BusinessException extends RuntimeException {

    /**
     * 错误码
     */
    private final int code;

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(String message) {
        super(message);
        this.code = -1;
    }

    public BusinessException(Errors errors, String message) {
        super(message);
        this.code = errors.getCode();
    }

    public BusinessException(Errors errors) {
        super(errors.getMessage());
        this.code = errors.getCode();
    }
}